﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NotAClue.ComponentModel.DataAnnotations
{
    /// <summary>
    /// Attribute to identify which column to use as a 
    /// parent column for the child column to depend upon
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = true)]
    public class ChangeAwareAttribute : Attribute
    {
        // this property is required to work with "AllowMultiple = true" ref David Ebbo
        // As implemented, this identifier is merely the Type of the attribute. However, 
        // it is intended that the unique identifier be used to identify two 
        // attributes of the same type.
        public override object TypeId { get { return this; } }

        /// <summary>
        /// Name of the parent column
        /// </summary>
        public String ParentColumn { get; private set; }

        /// <summary>
        /// This is the value the field looks for 
        /// for the true condition
        /// </summary>
        public String ValueWhenTrue { get; set; }

        /// <summary>
        /// Default Constructor sets ParentColumn
        /// to an empty string 
        /// </summary>
        public ChangeAwareAttribute()
        {
            ParentColumn = "";
            ValueWhenTrue = "";
        }

        /// <summary>
        /// Constructor to use when
        /// setting up a cascade column
        /// </summary>
        /// <param name="parentColumn">Name of column to use in cascade</param>
        public ChangeAwareAttribute(string parentColumn)
        {
            ParentColumn = parentColumn;
        }
    }
}